﻿$(function () {
    var ywId = getParam("id");
    loadTables(ywId);
});

function loadTables(ywId) {
    $("#Name").html("");
    $("#Timelimit").html("");
    $("#Charge").html("");
    $("#LegalBasis").html("");
    $("#ApplicationRequirements").html("");
    $("#ApplicationMaterials").html("");
    $("#Procedure").html("");
    $("#OfficeTel").html("");
    $("#OfficeAddress").html("");
    $("#Remarks").html("");
    $.ajax({
        type: "GET",
        url: "/Yw/GetByIdToJson?id=" + ywId + "&_t=" + new Date().getTime(),
        success: function (data) {
            if (notNull(data.name))
                $("#Name").html("<h1 class='page__title'>" + data.name + "</h1>");
            if (notNull(data.timelimit))
                $("#Timelimit").html("<section><h1>办理期限</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.timelimit + "</p></section>");
            if (notNull(data.charge))
                $("#Charge").html("<section><h1>收费标准</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.charge + "</p></section>");
            if (notNull(data.legalBasis))
                $("#LegalBasis").html("<section><h1>法律依据</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.legalBasis + "</p></section>");
            if (notNull(data.applicationRequirements))
                $("#ApplicationRequirements").html("<section><h1>申请条件</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.applicationRequirements + "</p></section>");
            if (notNull(data.applicationMaterials))
                $("#ApplicationMaterials").html("<section><h1>申请材料</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.applicationMaterials + "</p></section>");
            if (notNull(data.procedure))
                $("#Procedure").html("<section><h1>办理流程</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.procedure + "</p></section>");
            if (notNull(data.officeTel))
                $("#OfficeTel").html("<section><h1>咨询电话</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.officeTel + "</p></section>");
            if (notNull(data.officeAddress))   //如果为空，则不显示了
                $("#OfficeAddress").html("<section><h1>办理地点</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.officeAddress + "</p></section>");
            if (notNull(data.remarks))   //如果为空，则不显示了
                $("#Remarks").html("<section><h1>备注</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;" + data.remarks + "</p></section>");
        }
    })
};

//获取URL上的参数
function getParam(paramName) {
    paramValue = "";
    isFound = false;
    if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
        arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&");
        i = 0;
        while (i < arrSource.length && !isFound) {
            if (arrSource[i].indexOf("=") > 0) {
                if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
                    paramValue = arrSource[i].split("=")[1];
                    isFound = true;
                }
            }
            i++;
        }
    }
    return paramValue;
}

function notNull(args) {
    if (!args||args==null)
    { return false }
    else {
        if (args.length < 1)
            return false
    }
    return true
}